var Db = require('mongodb').Db,
    MongoClient = require('mongodb').MongoClient,
    Server = require('mongodb').Server,
    ReplSetServers = require('mongodb').ReplSetServers,
    ObjectID = require('mongodb').ObjectID,
    Binary = require('mongodb').Binary,
    GridStore = require('mongodb').GridStore,
    Grid = require('mongodb').Grid,
    Code = require('mongodb').Code,
    BSON = require('mongodb').pure().BSON,
    assert = require('assert');

MongoClient.connect('mongodb://127.0.0.1:27017/amobi', function(err, db) {
//while(true){
	var collection = db.collection('widget_advertiser_hour');
	collection.find({ city : "THANH PHO HO CHI MINH",
		  link_id : "446",
		  net : "2",
		  region : "4",
		  sms_code : "ADN1",
		  widget_code : "85234f9f3a501d50791a90e1b4c5c9fa",
		  widget_id : "0" }, {limit:5}).toArray(function(err, docs) {
        console.log(docs);
      });
//}
	
});
//var start=new Date();
//for(var i=1;i<=1000;i++){
//	var widget_advertiser_hour = db.collection('insert');
//	widget_advertiser_hour.insert({hello:i},function(err,cd){});
//}
//var end=new Date();
//console.log(end.getTime()-start.getTime());